package com.hsc.www;

import com.alibaba.fastjson.JSONObject;
import org.apache.catalina.Server;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.info.GitProperties;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;


@RestController
public class MyController {

    @Value("git.commit.id")
    private String gitCommitId;
    @Value("git.commit.message.full")
    private String gitCommitMessage;
    @Value("git.commit.time")
    private String gitCommitTime;
    @Value("git.commit.user.name")
    private String gitCommitUser;
    private static final String serverStartTime = new Date().toString();
    private static final String serverStartRandomID = UUID.randomUUID().toString();


    public MyController(GitProperties gitProperties) {
        System.out.println("ddddd:" + JSONObject.toJSONString(gitProperties));
    }

    @RequestMapping(value = "/*")
    public Map adminPage(HttpServletRequest request, HttpServletResponse response) {
        Map map = new HashMap();
        map.put("message", "adminPage");
        return map;
    }

    public static class ServerInfo {
        /**
         * git提交Id
         */
        private String gitCommitId;
        /**
         * git提交信息
         */
        private String gitCommitMessage;
        /**
         * git提交时间
         */
        private String gitCommitTime;
        /**
         * git提交人
         */
        private String gitCommitUser;
        /**
         * 服务启动时间
         */
        private String serverStartTime;
        /**
         * 服务启动随机ID
         */
        private String serverStartRandomID;
    }

}
